// import request from "@/utils/request";
import axios from "axios";

export default {
  paike(date, option) {
    // console.log(date,option);
    // return request({
    //     url: `${api_name}/excel/${date}/${option}`,
    //     method: "get",
    //   });
    
    // let url = `http://172.16.180.16:8080/paike/excel/${date}/${option}`
    let url = `http://localhost:8080/paike/excel/${date}/${option}`;
    axios
      .get(url, {
        responseType: "blob", // 指定响应类型为二进制数据
      })
      .then((response) => {
        const blob = new Blob([response.data], {
          type: "application/vnd.ms-excel",
        });
        const url = window.URL.createObjectURL(blob);
        const link = document.createElement("a");
        link.href = url;
        link.setAttribute("download", `${date}-${option}.xlsx`);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      })
      .catch((error) => {
        // 处理错误
      });
  },
};
